Questions
16 of 25
1How do you build a reusable pagination and sorting query DTO that can be extended by feature-specific DTOs in NestJS?
2How do you use ClassSerializerInterceptor with @Exclude() and @Expose() to control response shape in NestJS?
3What versioning strategies does NestJS support and how do you enable versioning?
4How do you implement idempotency keys for POST requests to prevent duplicate operations in NestJS?
5How do you implement API rate limiting per user or per IP in NestJS?
6How do you handle raw body access for webhook signature verification in NestJS?
7How do you stream a large file or dataset as a response without loading it fully into memory in NestJS?
8How do you implement content negotiation so an endpoint returns JSON or CSV based on the Accept header in NestJS?
9How do you set a default version so unversioned requests are handled by a specific version in NestJS?
10How do you document DTO properties for Swagger and handle optional vs required fields in NestJS?
11How do you handle HATEOAS hypermedia links in NestJS REST responses?
12What decorators does NestJS provide for route parameters and how do they differ from query params?
13How do you handle a route where the param can be either a numeric ID or the literal string 'me' in NestJS?
14How do you handle multi-value query parameters (arrays) in NestJS?
15What is the difference between @Body(), @Body('field'), and using a full DTO class in NestJS?
16How do you implement a PATCH endpoint correctly with partial validation using PartialType in NestJS?
17How do you implement discriminated union body validation where the DTO shape depends on a type field in NestJS?
18How do you set HTTP status codes, response headers, and redirects in NestJS without using @Res()?
19What is the recommended file structure for versioned controllers in a NestJS project?
20How do wildcard and optional route segments work in NestJS?
21What is the difference between @Param('id') and @Param() with no argument in NestJS?
22How do you extract and type query parameters in NestJS including optional ones with defaults?
23How do you implement a standard paginated response envelope across all list endpoints in NestJS?
24How do you apply versioning at controller and method level in NestJS and how do you mark a route as version-neutral?
25How do you set up Swagger in a NestJS application and annotate your controllers?
16 / 25

How do you implement a PATCH endpoint correctly with partial validation using PartialType in NestJS?

Use PartialType from @nestjs/mapped-types to create an UpdateDto where all fields are optional but retain their original validation decorators. Combine with skipMissingProperties: true in ValidationPipe so absent fields are not validated at all. This ensures PATCH only updates provided fields while still validating the ones that are sent.

PartialType for PATCH endpoint DTOs
PATCH endpoint best practices:
  1. 1

    PartialType wraps every field with @IsOptional() while preserving all other decorators.

  2. 2

    Also available from @nestjs/swagger — use that version to keep Swagger documentation accurate.

  3. 3

    skipMissingProperties: true in ValidationPipe skips validation for fields not sent in the request.

  4. 4

    PATCH should apply partial updates — only modify fields that are present in the request body.

  5. 5

    PUT should replace the entire resource — all required fields must be present in the body.

Difficulty: 6/10
Topics: PartialType, DTO validation, PATCH endpoint

Scenario Questions

0-2 years experience
  1. 1

    How would you implement a PATCH /users/:id endpoint that reuses the CreateUserDto with PartialType?

  2. 2

    What happens if a client omits a field that is required in the original DTO when you use PartialType?

  3. 3

    Can you sketch the DTO class and controller method code for this partial update?

2-5 years experience
  1. 1

    We added PartialType to our OrderUpdateDto but some fields are still being validated as required. Walk me through how you'd debug the issue.

  2. 2

    Explain the trade‑offs between using PartialType versus manually marking each property optional in a large DTO.

  3. 3

    If a client sends an empty JSON body to the PATCH endpoint, how would you ensure the request is rejected appropriately?

5-8 years experience
  1. 1

    When supporting partial updates for many resources, how would you design a reusable pattern with PartialType that minimizes performance impact?

  2. 2

    Describe how you would handle nested objects—like updating an address inside a UserDto—using PartialType and class‑validator.

  3. 3

    What considerations do you make for API versioning when the underlying DTO shape changes but old PATCH contracts must remain functional?

8+ years experience
  1. 1

    Our ecosystem has dozens of NestJS microservices. How would you architect a shared library for PartialType‑based DTOs, validation pipelines, and error handling while keeping services decoupled?

  2. 2

    If we decide to migrate from class‑validator to a custom validation framework, how would you refactor existing PartialType DTOs to reduce risk?

  3. 3

    Describe a long‑term maintenance strategy to keep partial update endpoints backward compatible as the data model evolves across teams.

Follow-up Questions

  • How does NestJS's ValidationPipe treat optional properties generated by PartialType?
  • If you needed to aggregate multiple validation errors into a single response, what would you change?
  • What unit or e2e tests would you write to verify the PATCH behavior?